package dao;

// Generated Mar 18, 2014 10:39:39 PM by Hibernate Tools 3.4.0.CR1
import java.util.List;
import javax.naming.InitialContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.hibernate.SessionFactory;
import org.hibernate.classic.Session;
import org.hibernate.criterion.Example;
import pojo.MobileHasAttribute;

/**
 * Home object for domain model class MobileHasAttribute.
 *
 * @see pojo.MobileHasAttribute
 * @author Hibernate Tools
 */
public class MobileHasAttributeHome {

    private static final Log log = LogFactory
            .getLog(MobileHasAttributeHome.class);

    private final Session session;

    public MobileHasAttributeHome(SessionFactory sessionFactory) {
        session = sessionFactory.openSession();
    }

    public void persist(MobileHasAttribute hasAttribute) {
        log.debug("persisting MobileHasAttribute instance");
        try {
            session.beginTransaction();
            session.persist(hasAttribute);
            session.getTransaction().commit();
            log.debug("persist successful");
        } catch (RuntimeException re) {
            log.error("persist failed", re);
            throw re;
        }
    }

    public void delete(MobileHasAttribute hasAttribute) {
        log.debug("deleting MobileHasAttribute instance");
        try {
            session.beginTransaction();
            session.delete(hasAttribute);
            session.getTransaction().commit();
            log.debug("delete successful");
        } catch (RuntimeException re) {
            log.error("delete failed", re);
            throw re;
        }
    }

//    public MobileHasAttribute merge(MobileHasAttribute detachedInstance) {
//        log.debug("merging MobileHasAttribute instance");
//        try {
//            MobileHasAttribute result = (MobileHasAttribute) sessionFactory
//                    .getCurrentSession().merge(detachedInstance);
//            log.debug("merge successful");
//            return result;
//        } catch (RuntimeException re) {
//            log.error("merge failed", re);
//            throw re;
//        }
//    }
//
//    public MobileHasAttribute findById(pojo.MobileHasAttributeId id) {
//        log.debug("getting MobileHasAttribute instance with id: " + id);
//        try {
//            MobileHasAttribute instance = (MobileHasAttribute) sessionFactory
//                    .getCurrentSession().get("pojo.MobileHasAttribute", id);
//            if (instance == null) {
//                log.debug("get successful, no instance found");
//            } else {
//                log.debug("get successful, instance found");
//            }
//            return instance;
//        } catch (RuntimeException re) {
//            log.error("get failed", re);
//            throw re;
//        }
//    }
//
//    public List findByExample(MobileHasAttribute instance) {
//        log.debug("finding MobileHasAttribute instance by example");
//        try {
//            List results = sessionFactory.getCurrentSession()
//                    .createCriteria("pojo.MobileHasAttribute")
//                    .add(Example.create(instance)).list();
//            log.debug("find by example successful, result size: "
//                    + results.size());
//            return results;
//        } catch (RuntimeException re) {
//            log.error("find by example failed", re);
//            throw re;
//        }
//    }
}
